#ifndef BASHAPP_H
#define BASHAPP_H

#include <iostream>
#include <filesystem.h>

using std::string;
using std::cout;
using std::cin;
using std::endl;

class BashApp
{
public:
    BashApp();
    
    BashApp(FileSystem* f) {
        exit_ = false;
        file_system_ = f;
        ShowInputLine();
    }
    
    /**
     * @brief ShowInputLine 显示等待输入的行
     */
    void ShowInputLine() {
        cin.sync();
        while(!exit_) {
            string input;
            cout << file_system_->GetOpeningPath() << ">";
            getline(cin, input);
            ParseCommand(input);
        }
    };
    
    /**
     * @brief ShowResult 显示结果
     * @param str
     */
    inline void ShowResult(string str) {
        cout << str << endl;
    }
    
    void ParseCommand(string str);
    
    void Cd(vector<string> command);
    
    void Watch(vector<string> command);
    
    void Update(vector<string> command);
    
    void Ls(vector<string> command);
    
    void Mkdir(vector<string> command);
    
    void Touch(vector<string> command);
    
    void Delete(vector<string> command);
    
private:
    FileSystem* file_system_;
    
    bool exit_;
    
};

#endif // BASHAPP_H
